home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_oth / lisp1 / lisp1.txt
Text File  |  1987-01-11  |  15KB  |  3 lines

  1. Copyright 1984 by Gary M. Rader╔═════════════════════════════════════════════════════════════════════════════╗║                   Why Not Lisp?                      ║║                                          ║║                    by                          ║║                                          ║║                   Gary M. Rader                      ║╚═════════════════════════════════════════════════════════════════════════════╝┌──────────────────────────────────┐│ Introduction               │└──────────────────────────────────┘           Browsing  through  almost any personal computer journal      will    yield  at  least  one  (if not many) programs computer      hobbyists can use on their personal computer. These programs      are  invariably  written  in    BASIC.    Occasionally one finds      programs written in Pascal, Assembly or, in what seems to be      the  current    favorite  of  software    developers,  C.  Other      languages  are mentioned in articles, often without programs      -  Fortran, Cobol, Forth, APL, Modula-2, Ada, and even Logo.      The  language  that  never seems to appear is Lisp. Why? The      impression  is  that Lisp is either subhuman (subcomputer?),      superhuman,  or  beyond comprehension. This article examines      some    of  the strengths and weaknesses of Lisp, and compares      it to other microcomputer languages.┌──────────────────────────────────┐│ History               │└──────────────────────────────────┘           Lisp   was  one    of  the  first    high  level  languages      developed  for  digital  computers.  Fortran    and Cobol were      developed  in  the  same time frame. Unlike those languages,      Lisp    has  never  been  standardized,  and  several dialects      exist.   MacLisp   from   the   Massachusetts  Institute  of      Technology  (MIT) and InterLisp from Stanford University are      two  main  dialects.    However,  one  dialect    can  generally      imitate another so lack of standardization usually causes no      serious problem.           Lisp  was initially developed by John McCarthy while at      MIT.    Traditionally,    it  has  been  used  mainly for symbol      manipulation,   primarily   in   the     area    of  artificial      intelligence.  Symbol  manipulation  is  the    complement  of      arithmetic.  It deals with structures as opposed to numbers.      Probably  the  most familiar symbol manipulation application      is  a  word  processing program in which words (symbols) are      manipulated. Other examples include compilers, interpreters,      data base systems, computer games, and business graphics. In      the  area of natural language processing, pluralizing a noun      such     as   "key"   to   "keys"  is  an  example  of  symbol      manipulation.           Historically,  Lisp  systems  were  slow  with  minimal      arithmetic   capabilities.   These  deficiencies  have  been      largely  overcome, but the image persists and Lisp is rarely      found  outside  university  environments. Another reason for      its  nonacceptance  was  the lack of good tutorial material.      The  arrival    of  Winston  and  Horn's  excellent  book LISP      (Addison  Wesley, 1981, paper) has rectified this situation.      (EDITOR'S  NOTE:  Apparently,  laziness  is  the  only valid      remaining  reason  not  to  learn Lisp.) This is the book of      choice for learning Lisp.┌──────────────────────────────────┐│ What Distinguishes Lisp?       │└──────────────────────────────────┘           What Distinguishes Lisp from other Languages?      1.   First,  Lisp  is  interactive, like BASIC and APL. This      greatly  speeds  program development and debugging. Like APL      (and     partly   like    BASIC)    variables  are    not  declared.      Developed programs can be compiled for increased speed.      2.   One  of Lisp's most powerful features is its ability to      generate  code  and  execute    it.  For example, to satisfy a      user's  query,  a  data base program might first generate an      appropriate  program    and  then execute (or "evaluate" as we      say  in  Lisp)  it.  APL  has  a similar capability. This is      possible  because Lisp programs and Lisp data have identical      structures.      3.   Lisp  compilers    are  unique  in that they can handle a      mixture  of  both  compiled  and  interpreted code. That is,      under Lisp a system of interpreted AND compiled programs can      be  run!  Some  of  these  programs can be compiled, and the      others  will    be  interpreted. This allows a program to have      the  speed  of  a  compiled  program together with the above      mentioned flexibility of "evaluating" generated code.      4.   Various    types  of  macros  facilitate translations and      redefinition    of  the  Lisp  language.  New languages can be      built from Lisp relatively easily using macros. The original      Logo was initially created this way.      5.   Another    powerful  feature is that of function types in      which  the  number  of  arguments  can be variable or fixed.      These arguments can be either evaluated or unevaluated. Most      languages  require  the number of arguments to be fixed. APL      allows  a  variable  number (as long as it is either 0, 1 or      2).  The  Lisp  function  PLUS  is a built-in function which      takes  a variable number of arguments. It can be used to add      an indefinite number of numbers, not just a pair of numbers.      The  evaluated/unevaluated  feature  is  similar to call-by-      value and call-by-name used in other languages.      6.   "Bignums" permit unlimited precision integer arithmetic      thereby  eliminating    the  problem  of  round-off errors. In      certain  engineering    and applied mathematics situations the      problem of round-off can be very serious.      7.   Strings,   functions, and  variable  names  can    be  of      unlimited  length.  This  allows  the creation of completely      descriptive names without the need for abbreviations.      8.   The  main Lisp data structure is the linked list, which      allows  the development of general structures, even circular      graphs.  The    links  (pointers) are transparent to the user.      Other  languages such as C allow this capability through the      explicit   manipulation  of  pointers.  Linked  lists  allow      certain  operations  to  be  performed much more efficiently      than when arrays are used.           Consider  an  array  of    numbers, say X(1), X(2), X(3),      etc.    To  insert  a new third element in this array we shift      each    element  to the next element in the array and set X(3)      to  the new number. In Lisp, this is accomplished by linking      X(2) to the new element, and then linking the new element to      X(3).  For  long  sequences  the  linked  list  approach  is      significantly faster than using arrays.      9.   Lisp is a functional language - it uses function calls,      and  this  makes  it    structured, almost naturally. All Lisp      programs  are systems of functions with a top level function      calling subfunctions and so on. New functions can be defined      in  isolation  and  used  as    if  they  were    primitive Lisp      operations.      10.  Lisp  has  perhaps  the    most powerful set of debugging      features  of    any  language. Break points can be set and the      environment    examined   when  a  break  occurs.  The  input      arguments  and  results of executing specified functions can      be  displayed  selectively during program execution. You can      create   unique   and   powerful   debugging    facilities  by      appropriately  redefining  the "evaluate function" mechanism      of Lisp.┌──────────────────────────────────┐│ Drawbacks               │└──────────────────────────────────┘      1.   One  drawback of present day Lisp is the reclamation of      memory.  Referred  to  as  "garbage  collecting,"  it occurs      automatically  when no free memory is available for creating      new  lists  or  strings  (BASIC  has    a  similar  drawback).      Processing stops (for a few seconds) until all unused memory      has  been  reclaimed. This can happen at any time during the      execution  of a program. In many cases it will be unnoticed,      but  it  can    happen    while a line is being displayed on the      screen! This creates quite a shock and can lead new users to      believe  the system has crashed. This also presents problems      for real time programming.           The problem can be reduced when necessary by explicitly      calling the garbage collector at points in the program where      the    user   will  not  notice,  and    by  pursuing  "garbage      collectionless  programming"  (by minimizing the creation of      new lists). Research on incremental garbage collectors which      reclaim a little bit of memory with each new usage of memory      will,  hopefully, solve  this  problem.  Compiling  programs      reduces  the    length of garbage collections as compiled code      does not need to be processed.           Despite     the   negative   impression   created    above,      automatic  memory  management  is  also  one of Lisp's great      strengths.  It  allows  the  programmer  to  concentrate  on      solving  the    problem  at  hand  without being distracted by      conceptually    irrelevant  details  concerning  memory (e.g.,      variable  declaration,  requesting memory from the operating      system, and  returning  memory  when no longer needed). This      undoubtedly is an important reason for Lisp's preeminence in      the world of artificial intelligence.      2.   Using  lists instead of arrays requires more memory, as      space for links must generally be provided.      3.   As data and programs can be widely dispersed in memory,      using  Lisp  in a virtual memory environment can cause speed      degradation.    While  following links to a desired data item,      the  page containing the actual item might be swapped out in      the  course  of tracking it down! Of course, this can happen      in  other languages such as C in which pointers can point to      other pointers, which point to other pointers.      4.   Many   people   complain   that     Lisp    has  too  many      parentheses.    This  is a prejudice, not a drawback. Usually,      if  functions  and  data  are  suitably  formatted  ("pretty      printed"),  this  objection disappears. For those preferring      fewer  parentheses,  the  Lisp  driver  can  be redefined to      provide it. (This was done for the Logo syntax.)┌──────────────────────────────────┐│ Lisp on the IBM PC           │└──────────────────────────────────┘           Several    Lisps  are currently available for the IBM PC.      The Soft Warehouse sells muLISP-83 (also sold by Microsoft),      Integral  Quality  markets  IQLISP,  and Norell Data Systems      offers LISP/88.           I  have    used muLISP-83 for almost half a year and have      been    pleasantly  impressed  by  its performance. I have not      used    IQLISP    but  from Integral Quality's brochure it seems      that    it is a fully functional Lisp. LISP/88 has just become      available  for  distribution,  and I have no experience with      this product.           muLISP  enforces  completely  structured programming by      not  having a GOTO command.(However, exits from loops can be      efficiently performed using the THROW/CATCH combination.) In      addition  to    the  expected  functionality,  muLISP provides      access to the PC's BIOS through its REGISTER, INTERRUPT, and      PORTIO  commands.  This  is  a  useful feature for it allows      programmers  to  easily  incorporate    graphics,  sound, game      paddle communication, and more in their programs. Random I/O      is  available.  muLISP  does    not provide arrays or floating      point  numbers.  (However  the  Soft    Warehouse is currently      implementing    floating slash - i.e., floating point in which      the  precision  is user-defined. This prevents the round-off      problem from resurfacing.)           A program development system and a debugging system are      included  with  muLISP  along  with utility files containing      libraries  of  MacLisp  and  InterLisp functions. An on-line      tutorial  for  learning  Lisp  is  also  included. (The Soft      Warehouse  had  developed a tutorial correlated with Winston      and  Horn's  LISP  book  but  Addison Wesley, the publisher,      demanded a royalty!)           A   nice   feature   for  program  developers  is  that      application  programs  written  in  muLISP  do  not  require      customers  to own the full muLISP system. A small royalty is      paid    for  use  of  the  muLISP runtime system. Programs are      distributed as .COM files.           IQLISP  uses all of the PC's memory while muLISP uses a      maximum of 256K bytes. Arrays and floating point numbers are      provided  as    is  8087  support. IQLISP does not have random      I/O.           Both Lisps allow user-defined machine language routines      to  be  called from within programs. Both include a "string"      data    type.  muLISP  is  allegedly  4 to 7 times faster than      IQLISP.  One    reason    is  that muLISP functions are compiled      into    "distilled"  code  (similar to Pascal's p-code) before      interpretation. Another is that IQLISP accommodates a larger      address space.           Both  companies    state  they  will  be  offering a Lisp      compiler.  When  I  contacted  Integral Quality last Spring,      they    indicated  that  a Lisp compiler would be available by      now.    To my knowledge, it is not yet available. The compiler      from the Soft Warehouse will be ready in late 1984.           LISP/88    may  or may not be in the same league as these      two.    However,  it  definitely  has  one notable feature - a      price of $49.95!┌──────────────────────────────────┐│ Conclusion               │└──────────────────────────────────┘           Unjustified    prejudices    continue    to    restrain      microcomputer  users    from  learning and using Lisp. Several      quality  microcomputer  implementations  are available along      with    an  excellent  book  for  learning Lisp. Lisp provides      powerful  capabilities,  many  of  which  are unavailable in      other languages.           Three  Lisps  are  currently available for the IBM PC -      muLISP,  IQLISP, and LISP/88. A review of muLISP, and IQLISP      appears in PC Magazine (December, 1983).             ┌───────────────────────────────────────┐             │     Products mentioned in this article  │             ├───────────────────────────────────────┤             │                         │             │    IQLISP ($175)                 │             │        Integral Quality             │             │        P. O. Box 31970             │             │        Seattle, Washington 98103         │             │        (206) 527-2918             │             │                         │             ├───────────────────────────────────────┤             │                         │             │    LISP/88 ($49.95)             │             │        Norell Data Systems          │             │        3400 Wilshire Blvd.          │             │        P. O. Box 70127             │             │        Los Angeles, California 90010    │             │        (213) 257-2026             │             │                         │             ├───────────────────────────────────────┤             │                         │             │    muLISP-83 ($250)             │             │        The Soft Warehouse             │             │        P. O. Box 11174             │             │        Honolulu, Hawaii 96828-0174      │             │        (808) 734-5801             │             │                         │             └───────────────────────────────────────┘             ┌──────────────────────────────────┐             │ File Name:  ██     lisp1.txt  ██    │             └──────────────────────────────────┘
  2.  
  3. ,Tû%───┐             parentheses,  the  Lisp  driver  can  be redefined to      provide it. (This was done for the Logo syntax.)┌──────────────────────────────────┐│ Lisp on the IBM PC           │└──────────────────────────────────┘           Several    Lisps  are currently available